import {get} from './request'
import {ref} from 'vue'

export function useStaffInfoApi(url:string,method:string,data?:any){
    const response = ref(null)
    const error:any = ref(null)

    //不会自己调用，只会返回给外界，让他们自己调用
    const fatchData = async ()=>{
        try{
            let request
            switch(method){
                case 'get':
                    request = await get(url,data)
                    break
                default:
                    throw new Error('method is error')
            }
            response.value = request.data
        }catch(err){
            error.value = err
        }
    }

    return {response,error,fatchData}
}